new Vue({
	el: '#app',
	data: {
		message: 'Hello Vue.js!',
		summary: {
			datetime: '',
			gender: '',
			calendar: '',
			year: '',
			month: '',
			day: '',
			hour: '',
			zodiac:'',
			type: ''
		},
		birthStemBranch: '',
		houseStemBranch: ''
	},
	methods: {
		changeMessage() {
			this.message = '你好，Vue.js！';
		},
		arrange() {
			if (this.disabled) {
				return;
			}
			this.disabled = true;
			if (!this.summary.datetime) {
				alert("请先选择日期");
				this.disabled = false;
				return;
			}
			var _this=this;
			axios.get('http://127.0.0.1/birth/stem/branch', {
					params: {
						date: this.summary.datetime
					}
				})
				.then(function(response) {
					
					// 请求成功时的处理
					if (response && response.status == 200) {

						if (response.data && response.data.code == 200) {
							console.log(response.data.data);
							_this.birthStemBranch=response.data.data;
							_this.summary.calendar=_this.birthStemBranch.calendar;
							_this.summary.zodiac=_this.birthStemBranch.zodiac;
							_this.summary.type=_this.birthStemBranch.year.stem.type;
							_this.summary.year=_this.birthStemBranch.year.stem.value+_this.birthStemBranch.year.branch.value+_this.birthStemBranch.year.unit;
							_this.summary.month=_this.birthStemBranch.month.stem.value+_this.birthStemBranch.month.branch.value+_this.birthStemBranch.month.unit;
							_this.summary.day=_this.birthStemBranch.day.stem.value+_this.birthStemBranch.day.branch.value+_this.birthStemBranch.day.unit;
							_this.summary.hour=_this.birthStemBranch.hour.stem.value+_this.birthStemBranch.hour.branch.value+_this.birthStemBranch.hour.unit;
							console.log(_this.summary)
						} else {
							alert("服务异常");
						}
					} else {
						alert("服务异常");
					}
				}).catch(function(error) {
					// 请求失败时的处理
					console.log(error);
				});
			this.disabled = false;
		}
	}
});